package com.exsun.gateway.jt809.kafka.gps;

import com.exsun.gateway.jt809.data.Interface.IGpsHandle;
import com.exsun.gateway.jt809.data.PushData;
import com.exsun.gateway.jt809.handler.SendMgrHandler;
import exsun.jt808.data.config.jt809.Jt809MsgIdConfig;
import exsun.jt808.data.jt809_data.BasicVehicleInfo;
import exsun.jt808.data.jt809_data.alarm.main.UpWarnMsgAdptInfo;
import exsun.jt808.data.upload_data.GpsData;

import java.util.ArrayList;
import java.util.List;

public class AlarmInfo implements IGpsHandle<List<UpWarnMsgAdptInfo>> {

    /**
     * 组包
     * @param data
     * @param sendMgrHandler
     * @return
     */
    public List<PushData> getPushData(List<UpWarnMsgAdptInfo> data, SendMgrHandler sendMgrHandler){
        List<PushData> pushs = new ArrayList<>();

        data.forEach(upWarnMsgAdptInfo -> {
            byte[] body = sendMgrHandler.jt809Encode.upWarnMsgAdptInfo(upWarnMsgAdptInfo);
            PushData pushData = new PushData(Jt809MsgIdConfig.UP_WARN_MSG, body);
            pushs.add(pushData);
        });
        return pushs;
    }
    /**
     * 数据转换
     * 报警信息,上级平台无需应答
     * @param positionInfo
     * @param basicVehicleInfo
     * @return
     */
    public List<UpWarnMsgAdptInfo> convert(GpsData positionInfo, BasicVehicleInfo basicVehicleInfo){
        return GpsConvert.alarmHandle(positionInfo,basicVehicleInfo);
    }


}
